"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var antd_1 = require("antd");
var react_1 = require("react");
var modulesUrl_1 = require("@/assets/constant/modulesUrl");
var tableList_1 = require("@/assets/components/tableList");
var DataViewList = function () {
    var _a = react_1.useState(), row = _a[0], setRow = _a[1];
    var columns = [
        {
            title: '规则名称',
            dataIndex: 'name',
            tip: '规则名称是唯一的 key',
            formItemProps: {
                rules: [
                    {
                        required: true,
                        message: '规则名称为必填项',
                    },
                ],
            },
            render: function (dom, entity) {
                return <a onClick={function () { return setRow(entity); }}>{dom}</a>;
            },
        },
        {
            title: '描述',
            dataIndex: 'desc',
            valueType: 'textarea',
        },
        {
            title: '服务调用次数',
            dataIndex: 'callNo',
            sorter: true,
            hideInForm: true,
            renderText: function (val) { return val + " \u4E07"; },
        },
        {
            title: '状态',
            dataIndex: 'status',
            hideInForm: true,
            valueEnum: {
                0: { text: '关闭', status: 'Default' },
                1: { text: '运行中', status: 'Processing' },
                2: { text: '已上线', status: 'Success' },
                3: { text: '异常', status: 'Error' },
            },
        },
        {
            title: '上次调度时间',
            dataIndex: 'updatedAt',
            sorter: true,
            valueType: 'dateTime',
            hideInForm: true,
            renderFormItem: function (item, _a, form) {
                var defaultRender = _a.defaultRender, rest = __rest(_a, ["defaultRender"]);
                var status = form.getFieldValue('status');
                if ("" + status === '0') {
                    return false;
                }
                if ("" + status === '3') {
                    return <antd_1.Input {...rest} placeholder="请输入异常原因！"/>;
                }
                return defaultRender(item);
            },
        }
    ];
    return (<tableList_1.default columns={columns} moduleUrl={modulesUrl_1.modulesUrl.reportSource} title={"数据源管理"}/>);
};
exports.default = DataViewList;
